package com.duing.controller;

import com.duing.entity.Fun;
import com.duing.service.FunService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/fun")
public class FunController {

    @Autowired
    private FunService service;

    @GetMapping("/")
   public List<Fun> selectAll(){
       return service.selectAll();
    }
    @GetMapping("/{fid}")
    public Fun selectFid(@PathVariable("fid") Integer fid){
        return service.selectFid(fid);
    }

    //通过json的格式返回层级关系
    @GetMapping("/Hierarchy")
    public List<Fun> selectHierarchy(){
        return service.selectHierarchy();
    }
}
